<?php
include_once '../data/database_dal.php';

class MarketDAL extends DatabaseDAL
{
    function update()
    {
        $this->connect();
        $result = $this->mysqli->query("call pr_market_update('". $id ."',)");
        $this->close();
        return $result;
    }

    function get($where)
    {
        $this->connect();
        $result = $this->mysqli->query("call pr_market_get(".'"'. $where .'"'.")");
        $this->close();
        return $this;
    }

    function getAll($orderBy)
    {
        $this->connect();
        $result = $this->mysqli->query("call pr_market_list(".'"'. $orderBy .'"'.")");
        $this->close();
        return ($result);
    }

    function delete($id)
    {
        $this->connect();
        $result = $this->mysqli->query("call pr_market_delete('". $id ."')");
        $this->close();
        return $result;
    }

    function validate($id, $market)
    {
        $result = $mysqli->query("call pr_category_validate('". $id ."', '". $market ."')");
        if ($result->fetch_row() > 0) {
            $result->close();
            return false;
        } else {
            $result->close();
            return true;
        }
    }
}
?>